package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.BillAccountQueryVo;
import cn.ywsj.ywsjmidtier.entity.VO.CreditApplicationVo;
import cn.ywsj.ywsjmidtier.entity.VO.DataParameterViewVo;
import cn.ywsj.ywsjmidtier.service.WechatCreditFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@Api(tags = "信誉信息")
@RestController
@RequestMapping("/wechat/member/credit")
public class WechatCreditController {

    @Autowired
    private WechatCreditFeign creditFeign;

    /**
     * 购物车_查询账期支付信息
     * @param orderId
     * @return
     */
    @ApiOperation("购物车_查询账期支付信息")
    @PostMapping("/getcreditaccount")
    public String getCreditAccount(String orderId) {
        return creditFeign.getCreditAccount(orderId);
    }

    /**
     * 我的供应商_保存授信信息
     * @param creditApplicationVo
     * @param session
     * @return
     */
    @ApiOperation("我的供应商_保存授信信息")
    @PostMapping("/toapplymethodforapp")
    public String toApplyMethodForApp(CreditApplicationVo creditApplicationVo,HttpSession session) {
        /*MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
        map.add("accountPeriod",creditApplicationVo.getAccountPeriod());
        map.add("amount",creditApplicationVo.getAmount());
        map.add("phone",creditApplicationVo.getPhone());
        map.add("remark",creditApplicationVo.getRemark());
        map.add("repaymentPeriod",creditApplicationVo.getRepaymentPeriod());
        map.add("smsCode",creditApplicationVo.getSmsCode());
        map.add("sysCode",creditApplicationVo.getSysCode());
        map.add("attachId",creditApplicationVo.getAttachId());
        map.add("imageAttachIdList",creditApplicationVo.getImageAttachIdList());*/
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(creditApplicationVo);
        return creditFeign.toApplyMethodForApp(jsonObject,session);
    }

    /**
     * 购物车_查询授信信息
     * @param toCustId
     * @return
     */
    @ApiOperation("购物车_查询授信信息")
    @PostMapping("/querycreditapplication")
    public String queryCreditApplication(String toCustId) {
        return creditFeign.queryCreditApplication(toCustId);
    }

    /**
     * 已还款未还款
     * @param queryVo
     * @param start
     * @param pageSize
     * @return
     */
    @ApiOperation("已还款未还款")
    @PostMapping("/ajaxcreditbill")
    public String  ajaxCreditBill(BillAccountQueryVo queryVo, Integer start, Integer pageSize){
        /*MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
        map.add("state",queryVo.getState());*/
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(queryVo);
        return creditFeign.ajaxCreditBill(jsonObject,start,pageSize);
    }

    /**
     * 我的账单
     * @param queryVo
     * @return
     */
    @ApiOperation("我的账单")
    @PostMapping("/querycredittotal")
    public String querycredittotal(BillAccountQueryVo queryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(queryVo);
        return creditFeign.querycredittotal(jsonObject);
    }

    @PostMapping(value = {"/getbillamountdetail"})
    public String getBillAmountDetail(BillAccountQueryVo queryVo) {
         return creditFeign.getBillAmountDetail(JsonObjectUtil.ObjectToJson(queryVo));
    }
}

